#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>


#define BUFF_LEN 100

#include "mychar.h"

//LED2 LED3 LED4 LED5分别被数字2、3、4、5控制 每按下一次 改变一次状态
int main(int argc, char *argv[]){
	int fd = -1;
	int led = 0;

	if(argc < 2){
		printf("too few arguments\n");
		return 1;
	}

	fd = open(argv[1], O_RDWR | O_NONBLOCK);

	if(fd < 0){
		printf("open failed : %s \n", argv[1]);
		return 2;
	}

	while(1){
		scanf("%d", &led);
		ioctl(fd, LED_CONTROL, &led);
	}

	close(fd);
	return 0;
}
